#include "usersmgr.h"

#include <QDebug>
#include <iostream>

UsersMgr::UsersMgr() {
}

UsersMgr::~UsersMgr() {
}

const UsersMgr::Users& UsersMgr::getUsers() const {
    return users_;
}

DBUsersMgr::DBUsersMgr(const QString &usersDbFile) : dbFileName_(usersDbFile) {
    connect();
}

DBUsersMgr::~DBUsersMgr() {
}

void DBUsersMgr::connect() {
    if(sqlite3_open(dbFileName_.toStdString().c_str(), &db_) == SQLITE_OK) {
        qDebug() << "Successfully opened the " << dbFileName_ << " database";
    } else {
        qDebug() << "Error opening the " << dbFileName_;
        qDebug() << "Error message: " << sqlite3_errmsg(db_);
    }
}

void DBUsersMgr::reload() {
    std::cin.get();
}

